package com.guoranhao.tool.constants;

/**
 * Description: 活动错误状态码枚举, 错误状态码范围：10000-20000
 * All Rights Reserved.
 * @version 1.0  2016年7月4日 下午2:49:10  by 代鹏（daipeng.456@gmail.com）创建
 */
public enum BaseErrorCodeEnum {

    ERRCODE_100000("100000", "系统错误"),
	ERRCODE_100001("100001", "必填项未填写或字段超长"),
	ERRCODE_100002("100002", "唯一性错误"),
	ERRCODE_100003("100003", "上传文件失败"),
	ERRCODE_100004("100004", "参数错误"),
	ERRCODE_100005("100005", "用户未登录或登录状态已失效"),
	ERRCODE_100006("100006", "无权限错误（如无页面权限，无当前操作权限）"),
	ERRCODE_100007("100007", "获取ip地址失败"),
	ERRCODE_100008("100008", "轮播图获取失败"),
	ERRCODE_100009("100009", "功能图标查询失败"),
	ERRCODE_100010("100010", "文章查询失败"),
	ERRCODE_100011("100011", "查询分类信息失败"),
	ERRCODE_100012("100012", "购物车数量查询失败"),
	ERRCODE_100013("100013", "购物车列表查询失败"),
	ERRCODE_100014("100014", "添加购物车失败"),
	ERRCODE_100015("100015", "商品查询失败"),
	ERRCODE_100016("100016", "查询详情失败"),
	ERRCODE_100017("100017", "商品已下架"),
	;

	private String code;
	private String msg;

	private BaseErrorCodeEnum(String code, String msg) {
		this.code = code;
		this.msg = msg;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	public static BaseErrorCodeEnum getByErrorCode(int code){
		for(BaseErrorCodeEnum errorCodeEnum : BaseErrorCodeEnum.values()){
			if(errorCodeEnum.getCode().equals(code)){
				return errorCodeEnum;
			}
		}
		return null;
	}

}
